package com.tangsm.spring.boot.springdoc.controller;

import cn.hutool.core.date.LocalDateTimeUtil;
import com.tangsm.spring.boot.springdoc.api.UserSimulationApi;
import com.tangsm.spring.boot.springdoc.domain.dto.User;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.math.BigDecimal;

/**
 * 模拟用户添加删除（非数据库操作）
 *
 * @author tangsm
 * @date 2021-07-27 10:48:25
 */
@RestController
@RequestMapping("/user-simulation")
public class UserSimulationController implements UserSimulationApi {
    private static final Logger log = LoggerFactory.getLogger(UserSimulationController.class);

    @PostMapping("/add/{name}")
    @Override
    public User addUser(@PathVariable String name) {
        return new User(1L, name, LocalDateTimeUtil.parseDate("2003-08-28"), 18, new BigDecimal("1000"));
    }

    @GetMapping("/del/{name}")
    @Override
    public void delUser(@PathVariable String name) {
        log.info("删除name={}的用户", name);
    }
}
